Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory tracking and garbage collection to CLASS v3.2.0 #583

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kcroker
Copy link

@kcroker kcroker commented Jul 18, 2024

Addresses Open Issues: #176 and possibly #528
Impacts Users: @hdp1213 @carlosggarcia @danielsf @mcosta18

Replaces all malloc(), realloc(), calloc(), and free() calls with reference-tracked versions. POSIX semantics are honoured. This allows all allocated memory to be freed at any time, regardless of CLASS state. FAILURE conditions have been adjusted to release all allocated memory.

This repairs memory leaks that occur when CLASS is driven from the python wrapper, but fails to complete computations for various reasons, e.g. untabulated He fraction in the reionization code, choices of model parameters during MC that result in non-viable cosmologies/intergrator precision issues, etc.

Memory is tracked with a minimal doubly-linked list. Additions occur at the head for maximal performance on allocation and free. Cooperates with OpenMP as it is used within the v3.2.0 code.

(Note that this patch does not introduce tracked memory allocations within the python wrapper, and so will not fix leaks within the wrapper, if they exist.)

kcroker and others added 3 commits September 3, 2023 23:58
        and Python classy.  Works in parallel with OpenMP (default
        100 threads, can be adjusted at compile time)

FIXES   memory leaks when CLASS terminates on _FAILURE_ when called
        from Python.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant